package com.rivulet.foreign.mapper;

import com.rivulet.foreign.pojo.Vacation;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * {一句话形容此class功能}
 *
 * @author xujiac
 * @create 2021/6/3
 * @since 1.0.0
 */
@Component
public interface VacationMapper {
    /**
     * 获得指定学号的相关的事假申请信息
     *
     * @param user_id
     * @return
     */
    @Select("select * from t_vacation where user_id=#{user_id}")
    public Vacation getVacationById(@Param("user_id") String user_id);

    /**
     * 获得所有未审批的学生事假申请信息
     *
     * @return
     */
    @Select("select * from t_vacation where is_yes is NULL")
    public List<Vacation> getAllYetVacation();

    /**
     * 新增学生事假申请信息
     *
     * @param user_id
     * @param classes
     * @param reason
     * @param begin_time
     * @param end_time
     * @param duration_time
     * @param destination
     */
    @Insert("insert into t_vacation (user_id,classes,reason,begin_time,end_time,duration_time,destination) " +
            "values (#{user_id},#{classes},#{reason},#{begin_time},#{end_time},#{duration_time},#{destination})")
    public void setVacation(@Param("user_id") String user_id,
                            @Param("classes") String classes,
                            @Param("reason") String reason,
                            @Param("begin_time") Date begin_time,
                            @Param("end_time") Date end_time,
                            @Param("duration_time") Integer duration_time,
                            @Param("destination") String destination);

    /**
     * 辅导员审批意见
     *
     * @param user_id
     * @param advice
     */
    @Update("update t_vacation set counselor_advice=#{advice} where user_id=#{user_id}")
    public void setCounselorAdvice(@Param("user_id") String user_id, @Param("advice") Integer advice);

    /**
     * 留学生管理处审批意见
     *
     * @param user_id
     * @param advice
     */
    @Update("update t_vacation set foreign_manager_advice=#{advice} where user_id=#{user_id}")
    public void setManagerAdvice(@Param("user_id") String user_id, @Param("advice") Integer advice);

    /**
     * 学院审批意见
     *
     * @param user_id
     * @param advice
     */
    @Update("update t_vacation set college_advice=#{advice} where user_id=#{user_id}")
    public void setCollegeAdvice(@Param("student_id") String user_id, @Param("advice") Integer advice);

    /**
     * 确认事假申请的审批结果
     *
     * @param user_id
     * @param is_yes
     */
    @Update("update t_vacation set is_yes=#{is_yes} where user_id=#{user_id}")
    public void setIsYes(@Param("user_id") String user_id, @Param("is_yes") Integer is_yes);

    /**
     * 删除指定user_id的事假申请信息
     *
     * @param user_id
     */
    @Delete("delete from t_vacation where user_id=#{user_id}")
    public void delVacation(@Param("user_id") String user_id);
}
